//
//  imagePropertyView.m
//  PhotoCircle
//
//  Created by wujungao on 12/28/15.
//  Copyright © 2015 wujungao. All rights reserved.
//

#import "imagePropertyView.h"
#import "imagePropertyModel.h"
#import "GMString.h"

#define imagePropertyViewH 361

@interface imagePropertyView()

@property (weak, nonatomic) IBOutlet UILabel *modelLabel;
@property (weak, nonatomic) IBOutlet UILabel *isoLabel;
@property (weak, nonatomic) IBOutlet UILabel *whileBalanceLabel;
@property (weak, nonatomic) IBOutlet UILabel *flashLabel;
@property (weak, nonatomic) IBOutlet UILabel *maderLabel;
@property (weak, nonatomic) IBOutlet UILabel *shutterLabel;
@property (weak, nonatomic) IBOutlet UILabel *apertureLabel;
@property (weak, nonatomic) IBOutlet UILabel *focalLengthLabel;
@property (weak, nonatomic) IBOutlet UILabel *dimensionLabel;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UIButton *closeBtn;
@property (weak, nonatomic) IBOutlet UIView *blackLineView;

- (IBAction)closeBtnAction:(UIButton *)sender;

@end

@implementation imagePropertyView

-(void)awakeFromNib{
    
    [self configBtn];
}

-(void)configLabelWithImagePropertyModel:(imagePropertyModel *)model{
    
    NSString *modelstr;
    if([NSString isEmptyString:model.deviceModel]){
        
        modelstr=[NSString stringWithFormat:@"型号:"];
        
    }else{
        
        modelstr=[NSString stringWithFormat:@"型号:%@",model.deviceModel];
    }
    self.modelLabel.text=modelstr;
    
    NSString *isoStr;
    if([NSString isEmptyString:model.iso]){
        
        isoStr=[NSString stringWithFormat:@"ISO:"];
        
    }else{
        
        isoStr=[NSString stringWithFormat:@"ISO:%@",model.iso];
    }
    self.isoLabel.text=isoStr;
    
    NSString *wb;
    if([NSString isEmptyString:model.whiteBalance]){
        
        wb=[NSString stringWithFormat:@"白平衡:"];
        
    }else{
        
        wb=[NSString stringWithFormat:@"白平衡:%@",model.whiteBalance];
    }
    self.whileBalanceLabel.text=wb;
    
    NSString *flashStr;
    if ([NSString isEmptyString:model.flash]) {
        
        flashStr=[NSString stringWithFormat:@"闪光灯:"];
        
    }else{
        
        flashStr=[NSString stringWithFormat:@"闪光灯:%@",model.flash];
    }
    self.flashLabel.text=flashStr;
    
    NSString *makerStr;
    if([NSString isEmptyString:model.maker]){
        
        makerStr=[NSString stringWithFormat:@"制造商:"];
        
    }else{
        
        makerStr=[NSString stringWithFormat:@"制造商:%@",model.maker];
    }
    self.maderLabel.text=makerStr;
    
    NSString *exposureTimeStr;
    if([NSString isEmptyString:model.exposureTime]){
        
        exposureTimeStr=[NSString stringWithFormat:@"快门:"];
        
    }else{
        
        exposureTimeStr=[NSString stringWithFormat:@"快门:%@",model.exposureTime];
    }
    self.shutterLabel.text=exposureTimeStr;
    
    NSString *apertureValueStr;
    if([NSString isEmptyString:model.apertureValue]){
        
        apertureValueStr=[NSString stringWithFormat:@"光圈:"];
        
    }else{
        
        apertureValueStr=[NSString stringWithFormat:@"光圈:%@",model.apertureValue];
    }
    self.apertureLabel.text=apertureValueStr;
    
    NSString *dateStr;
    if([NSString isEmptyString:model.date]){
        
        dateStr=[NSString stringWithFormat:@"时间:"];
        
    }else{
        
        dateStr=[NSString stringWithFormat:@"时间:%@",model.date];
    }
    self.dateLabel.text=dateStr;
    
    NSString *focalLenghtStr;
    if([NSString isEmptyString:model.focalLenght]){
        
        focalLenghtStr=[NSString stringWithFormat:@"焦距:"];
        
    }else{
        
        focalLenghtStr=[NSString stringWithFormat:@"焦距:%@",model.focalLenght];
    }
    self.focalLengthLabel.text=focalLenghtStr;
    
    NSString *wh;
    if([NSString isEmptyString:model.size]){
        
        wh=[NSString stringWithFormat:@"尺寸:"];
        
    }else{
        
        wh=[NSString stringWithFormat:@"尺寸:%@",model.size];
    }
    self.dimensionLabel.text=wh;
}

#pragma mark - btn action
- (IBAction)closeBtnAction:(UIButton *)sender {
    
    [UIView animateWithDuration:0.3 animations:^{
        
        self.frame=CGRectMake(0, SCREEN_H+imagePropertyViewH, SCREEN_W, imagePropertyViewH);        
    }];
}

#pragma mark - config view
-(void)configBtn{
    
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){204.0/255.0,204.0/255.0,204.0/255.0,1});
    
    self.closeBtn.layer.cornerRadius=self.closeBtn.bounds.size.height/2.0;
    [self.closeBtn.layer setBorderWidth:1.0];
    [self.closeBtn.layer setBorderColor:colorref];
    [self.closeBtn setTitle:@"关闭" forState:UIControlStateNormal];
    [self.closeBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.closeBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateHighlighted];
}

@end
























